﻿#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <easyx.h>
#include "sprite.h"
#include <string.h>
#include "gameloop.h"
#include "hero.h"
#include "backgroung.h"
#include "vector.h"
#include "scene.h"
#include "mainsene.h"
#include "menuScene.h"
int main()
{
	initgraph(422, 750);
	setbkcolor(WHITE);
	cleardevice();
	/*hero h;
	heroInit(&h);
	gameLoop((sprite*)&h, 60);
	heroDestroy(&h);*/

	/*background b;
	backgroundInit(&b);
	gameLoop((scene*)&b, 60);
	backgroundDestroy(&b);
	closegraph();*/
	//struct vector vec;
	//vectorInit(&vec);
	//struct student* s1 = (struct student*)malloc(sizeof(struct student));
	//s1->id = 1;
	//strcpy(s1->name, "小明");
	//s1->gender=1;
	//s1->mark = 90;
	//vec.append(&vec, s1);
	//for (int i = 0; i < vec.size; i++)//Capacity是初始长度
	//{
	//	struct student* s = (struct student*)vec.get(&vec, i);
	//	printf("%d %s %d %d\n", s->id,s->name ,s->gender, s->mark );
	//}
	//
	//struct student* s2 = (struct student*)malloc(sizeof(struct student));
	//s1->id = 2;
	//strcpy(s1->name, "小宏");
	//s1->gender = 0;
	//s1->mark = 92;
	//vec.append(&vec, s2);

	//for (int i = 0; i < vec.size; i++)//Capacity是初始长度
	//{
	//	struct student* s = (struct student*)vec.get(&vec, i);
	//	printf("%d %s %d %d\n", s->id, s->name, s->gender, s->mark);
	//}
	//printf("size:%d\n", vec.size);
	//printf("capacity:%d\n", vec.capacity);
	
	while(1)
	{
		menuScene menuscene;
		menuSceneInit(&menuscene);
		gameLoop((scene*)&menuscene, 60);
		menuSceneDestroy(&menuscene);


		//游戏场景
		ms MS;
		mainSceneInit(&MS);
		gameLoop((struct scene*)&MS, 60);
		mainSceneDestroy(&MS);

		//游戏结束后显示得分
		settextcolor(WHITE);
		settextstyle(100, 0, "微软雅黑");

		//显示游戏结束
		const char* pStr = "游戏结束";
		RECT r = { 0,200,422,300 };
		drawtext(pStr, &r, DT_CENTER);
		//显示得分
		char buff[10];
		sprintf(buff, "得分：%d", MS.mark);
		r = { 0,300,422,400 };
		drawtext(buff, &r, DT_CENTER);
		/*menuScene menuscene;
		menuscene.bk = new IMAGE;
		loadimage(menuscene.bk, "img/menu.png");*/
		//putimage(0, 0, menuscene.bk);//绘制背景图片
		Sleep(3000);
		//getchar();
	}
	closegraph();

	return 0;
}

//int main()
//{
//	initgraph(800, 600);
//	setorigin(400, 300);
//	setaspectratio(1, -1);
//	setbkcolor(RGB(164, 225, 202));
//	cleardevice;
//	int x = 0, y = 0;
//	int vx = 5, vy = 5;
//	int r = 20;
//	while (1)
//	{
//		cleardevice();
//		solidcircle(x, y, r);
//		Sleep(40);
//		if (y >= 300 - r || y <= -300 + r)
//		{
//			vy = -vy;
//		}
//		if (x <= -400 + r || x >= 400 - r)
//		{
//			vx = -vx;
//		}
//		x += vx;
//		y += vy;
//	}
//
//
//	getchar();
//	closegraph();
//	return 0;
//}